package cn.com.zzz.services;

import cn.bbs.ba.base.BAService;
import cn.bbs.ba.base.UserInfo;
import cn.bbs.ba.error.BAErrorMessage;
import cn.bbs.ba.factory.BABeanFactory;
import cn.bbs.ba.html.ZPaiInit;
import cn.bbs.ba.util.CommonUntil;
import cn.com.zzz.dao.PPJFDao;
import cn.com.zzz.dao.PPUserInfoDao;
import cn.com.zzz.pk.dto.PkJF;
import cn.com.zzz.util.Constant;
import cn.com.zzz.util.DataFormatUtil;

/**
 * 用户表相关业务
 * @author SL400
 */
public class UserServices extends BAService{

	public String checkEX(UserInfo dto) {
		PPUserInfoDao userInfoDao = (PPUserInfoDao)BABeanFactory.getBean("userInfoDao");
		UserInfo userInfo = userInfoDao.getUser(dto);
		UserInfo retDto = new UserInfo();
		// 用户不存在的场合
		if (userInfo == null) {
			retDto.setHostRetCode(Constant.MSG_10001);
			retDto.setHostMessage(BAErrorMessage.push(Constant.MSG_10001));
		}
		// 有数据的场合
		else {
			
			retDto.setHostRetCode(Constant.MSG_0000);
			retDto.setHostMessage(Constant.MSG_SUCCESS);
			retDto.setAlias(userInfo.getAlias());
			retDto.setUserNo(userInfo.getUserNo());
			retDto.setUserName(userInfo.getUserName());
			retDto.setKbn(userInfo.getKbn());
			
			PPJFDao jfDao = (PPJFDao)BABeanFactory.getBean("JF");
			PkJF jf = new PkJF();
			jf.setUserNo(userInfo.getUserNo());
			jf = jfDao.getJF(jf, "0").get(0);
			retDto.setValue("nowMoney", jf.getDqfs());
			
			String code = CommonUntil.getCode();
			ZPaiInit.getUserMap().put(userInfo.getUserNo(), code);
			retDto.setValue("logonUserID", code);
		}
		return DataFormatUtil.formatRetData(retDto);
	}
}
